package com.um.jdy.platform.alarm.controller;

import com.um.jdy.platform.alarm.entity.dto.AlarmNoticePageDTO;
import com.um.jdy.platform.alarm.entity.vo.AlarmNoticetemVO;
import com.um.jdy.platform.alarm.manager.AlarmNoticeManager;
import com.um.jdy.common.alarm.entity.dto.AlarmNoticeDTO;
import com.um.jdy.common.alarm.entity.po.AlarmNotice;
import com.um.jdy.common.alarm.entity.vo.AlarmNoticeVO;
import com.um.jdy.common.alarm.service.AlarmNoticeService;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.LoginRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BasePlusController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.params.ListDTO;
import com.um.springboot.starter.orm.params.PageParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 控制器：告警通知
 */
@RestController
@RequestMapping("/api/v1/cms/alarm/notice")
@Api(tags = "告警通知", description = "告警通知")
@ApiPermission("alarm_notice")
@LoginRequired
public class AlarmNoticeController extends BasePlusController<AlarmNoticeManager, AlarmNoticeService, AlarmNotice, AlarmNoticeDTO, AlarmNoticeVO, AlarmNoticePageDTO, ListDTO> {

    /**
     * 查询分页
     * @param params
     * @return
     */
    @ApiPermission("page")
    @ApiOperation(value = "分页告警通知")
    @PostMapping("/get_page")
    public Response<Page<AlarmNoticetemVO>> getNoticePage(@RequestBody AlarmNoticePageDTO params){
        PageParams pageParams = params.toPageParams(new String[]{"deviceStationId","level","code"},
                new String[]{"n.device_station_id","n.level","n.error_code"});
        return manager.getRecordPage(pageParams);
    }
}
